import {
  ClientNamespace,
  DEFAULT_REDIS_NAMESPACE,
  getRedisToken,
} from '@liaoliaots/nestjs-redis';
import { namespaces } from '@liaoliaots/nestjs-redis/dist/redis/common';
import { Inject } from '@nestjs/common';

export const InjectRedis = (
  namespace: ClientNamespace = DEFAULT_REDIS_NAMESPACE,
): PropertyDecorator => {
  const token = getRedisToken(namespace);
  namespaces.set(namespace, token);
  return Inject(token);
};
